package com.hopes.bizz.risk.statistic.vo;

import cn.hutool.core.util.ObjectUtil;
import com.hopes.bizz.risk.common.constant.enums.RiskModDictEnum;
import com.hopes.bizz.risk.common.constant.enums.RiskSysDictEnum;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.admin.api.resolver.DictResolver;
import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * @author yumr
 * @Description 风险对象管控统计VO
 * @time 2023/8/1 14:09
 */
@Data
public class RiskObjectStatisticVO implements Serializable {

    private static final long serialVersionUID = 6992620922866244438L;

    private Long riskObjectId;

    private Integer riskLevel;

    private Integer riskControlMeasureNum;

    public String getRiskLevelStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_level, this.getRiskLevel());
    }

    public String getRiskObjectIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_object, this.getRiskObjectId());
    }

    public String getRiskLevelColor() {
        final SysDictItem itemByValue = DictResolver.getItemByValue(
                RiskSysDictEnum.risk_level, Optional.ofNullable(this.getRiskLevel()).map(String::valueOf).orElse(null));
        if (ObjectUtil.isNotNull(itemByValue)) {
            return itemByValue.getExt1();
        }
        return null;
    }

}
